use std::error::Error;
use std::fmt;

#[derive(Debug)]
pub enum RemoteError {
    ConnectionFailed,
    SerializationFailed,
    DeserializationFailed,
    InvalidMessage,
    Timeout,
    SystemError(String),
}

impl fmt::Display for RemoteError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            RemoteError::ConnectionFailed => write!(f, "Connection failed"),
            RemoteError::SerializationFailed => write!(f, "Failed to serialize message"),
            RemoteError::DeserializationFailed => write!(f, "Failed to deserialize message"),
            RemoteError::InvalidMessage => write!(f, "Invalid message format"),
            RemoteError::Timeout => write!(f, "Operation timed out"),
            RemoteError::SystemError(msg) => write!(f, "System error: {}", msg),
        }
    }
}

impl Error for RemoteError {}

#[derive(Debug)]
pub enum SendError {
    MailboxFull,
    ConnectionFailed,
    SerializationFailed,
    Timeout,
    SystemError(String),
}

impl fmt::Display for SendError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            SendError::MailboxFull => write!(f, "Mailbox is full"),
            SendError::ConnectionFailed => write!(f, "Connection failed"),
            SendError::SerializationFailed => write!(f, "Failed to serialize message"),
            SendError::Timeout => write!(f, "Operation timed out"),
            SendError::SystemError(msg) => write!(f, "System error: {}", msg),
        }
    }
}

impl Error for SendError {}

#[derive(Debug)]
pub enum CompressionError {
    CompressionFailed(String),
    DecompressionFailed(String),
    InvalidData(String),
}

impl fmt::Display for CompressionError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            CompressionError::CompressionFailed(msg) => write!(f, "Compression failed: {}", msg),
            CompressionError::DecompressionFailed(msg) => write!(f, "Decompression failed: {}", msg),
            CompressionError::InvalidData(msg) => write!(f, "Invalid data: {}", msg),
        }
    }
}

impl Error for CompressionError {} 